using System.ComponentModel;

namespace CthulhuDomain.GameEntities
{
  public class CthulhuFactory : DomainFactory
  {
    public override DomainEntity CreateEntity(IContentManager manager)
    {
      return CreateEntity(manager, new CthulhuState
                                     {
                                       StartingPosition = new Vector2Adapter(0, 0),
                                       LifePoints = 1
                                     });
    }

    public override DomainEntity CreateEntity(IContentManager manager, EntityState state)
    {
      var entity = new Cthulhu(state.StartingPosition) { LifePoint = state.LifePoints, Texture = manager.LoadTexture("alien1") };
      entity.MovementStrategy = new Strategies.ZigStrategy(entity);
      entity.ProtoTypeChild = GetFactory(eTypeEntity.Shoot).CreateEntity(manager);
      entity.ContentManager = manager; return entity;
    }
  }

  public abstract class EntityStateFactory
  {
    public static EntityStateFactory GetFactory(DomainFactory.eTypeEntity type) {
      EntityStateFactory factory;
      switch (type) {
        case DomainFactory.eTypeEntity.Cthulhu:
          factory = new CthulhuStateFactory();
          break;
        default:
          throw new InvalidEnumArgumentException();
      }
      return factory;
    }

    public abstract EntityState CreateEntityState();
  }

  public class CthulhuStateFactory : EntityStateFactory
  {
    public override EntityState CreateEntityState()
    {
      return new CthulhuState();
    }
  }
}